extends Node2D
@export var eye_color:Color
var behitted:bool=false
func _ready() -> void:
	$PlayerDisplayer.eye_color=eye_color
	$PlayerDisplayer.pupil_radius=randf_range(0.07,0.12)
	$PlayerDisplayer.open_progress=0
func open()->void:
	behitted=false
	var twn:Tween=create_tween()
	twn.tween_property($PlayerDisplayer,"open_progress",randf_range(1.5,1.8),0.5)
	twn.tween_property($EyeArea,"monitoring",true,0)
	twn.tween_callback(func():
		if not behitted:
			$EyeArea.set_deferred("monitoring",false)
			$PlayerDisplayer.open_progress=0
		).set_delay(randf_range(1.5,3))

func _on_eye_area_area_entered(area: Area2D) -> void:
	$EyeArea.set_deferred("monitoring",false)
	Global.camera_effect.emit("dwell_frame")
	Global.camera_effect.emit("shake")
	behitted=true
	$Explosion.play()
	$BlackHole.visible=true
	$PlayerDisplayer.open_progress=0
	await get_tree().create_timer(0.5).timeout
	$BlackHole.visible=false
